package cn.zhangchg.leetcode.number;

public class Replace2Empty {

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            int replace = replace(i);
            System.out.println(i + ":" + replace);
        }
        //replace(5);
    }

    public static int replace(int x) {
        if (x < 2) {
            return x;
        }
        int replace = replaceEmpty(x);
        return x + replace;
    }

    public static int replaceEmpty(int x) {
        if (x < 2) {
            return 0;
        }
        int replace = x / 2 + replaceEmpty(x / 2 + x % 2);
        return replace;
    }
}
